//
//  FindMainTableViewCell.m
//  HJZWeiBo
//
//  Created by lanou on 16/5/27.
//  Copyright © 2016年 蒋晨成. All rights reserved.
//

#import "FindMainTableViewCell.h"
#import <UIImageView+WebCache.h>
@implementation FindMainTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 30, 30)];
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.iconImageView.frame.origin.x + self.iconImageView.frame.size.width + 5, self.iconImageView.frame.origin.y, 150, 30)];
        self.detailLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.titleLabel.frame.origin.x + self.titleLabel.frame.size.width + 5, self.iconImageView.frame.origin.y, 300, 30)];
        self.detailLabel.font = [UIFont systemFontOfSize:14];
        self.detailLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_iconImageView];
        [self.contentView addSubview:_titleLabel];
        [self.contentView addSubview:_detailLabel];
        
    }
    return self;
}



- (void)setModel:(FindMainTableViewModel *)model{
    _model = model;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:_model.pic]];
    self.titleLabel.text = _model.desc;
    self.detailLabel.text = _model.desc_extr;
    CGFloat titleWidth = [_titleLabel.text boundingRectWithSize:CGSizeMake(MAXFLOAT, 30) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil].size.width;
    CGRect frame = CGRectMake(self.titleLabel.frame.origin.x + titleWidth + 5, self.iconImageView.frame.origin.y, 300, 30);
    self.detailLabel.frame = frame;
}


@end
